﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Mobile.master" AutoEventWireup="true"
    CodeFile="car-quote.aspx.cs" Inherits="car_insurance_car_quote" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <%--<div id="wrapper">--%>
    <div class="fix-header">
        <div class="header">
            <a href="../home.aspx">
                <div class="logo-text">
                    GluayGluay
                </div>
            </a>
        </div>
        <div id="new-code" style="display: none;">
            <div class="new-code">
                <asp:ImageButton runat="server" ID="ibtnNewQuote" AlternateText="" ImageUrl="" Width="81px" Height="29px" OnClick="ibtnNewQuote_Click" />
            </div>
        </div>
    </div>
    <%--  <asp:UpdatePanel ID="upnlCarDetails" runat="server">
            <ContentTemplate>--%>
    <div id="divCarYear" runat="server">
        <div class="container">
            <div class="radius-box">
                <asp:Label ID="lblCarYearTitle" runat="server" Text=""></asp:Label>
            </div>
            <div id="ltrCarYear" runat="server">
            </div>
        </div>
    </div>
    <div id="divCarMake" runat="server" style="display: none;">
        <div class="container">
            <div class="radius-box">
                <asp:Label ID="lblCarMakeTitle" runat="server" Text=""></asp:Label>
            </div>
            <div id="ltrCarMake">
            </div>
        </div>
    </div>
    <div id="divCarModel" runat="server" style="display: none;">
        <div class="container">
            <div class="radius-box">
                <asp:Label ID="lblCarModelTitle" runat="server" Text=""></asp:Label>
            </div>
            <div id="ltrCarModel">
            </div>
        </div>
    </div>
    <div id="divCommence" runat="server" style="display: none;">
        <div class="container">
            <div class="radius-box">
                <asp:Label ID="lblCommencementTitle" runat="server" Text=""></asp:Label>
            </div>
            <div id="ltrCommencement" runat="server">
            </div>
        </div>
    </div>
    <%-- </ContentTemplate>
        </asp:UpdatePanel>--%>
    <div id="call-btn" style="display:none;">
        <a href="tel:022688222">
            <img src="../images/call-btn.png" width="227" height="47" alt=""></a></div>
    <div>
        <asp:HiddenField ID="hdnUserLoginStatus" runat="server" Value="0" />
        <asp:HiddenField ID="hdnCarYear" runat="server" Value="0" />
        <asp:HiddenField ID="hdnCarMake" runat="server" Value="0" />
        <asp:HiddenField ID="hdnCarMakeDesc" runat="server" Value="0" />
        <asp:HiddenField ID="hdnCarModel" runat="server" Value="0" />
        <asp:HiddenField ID="hdnCarModelDesc" runat="server" Value="0" />
        <asp:HiddenField ID="hdnCommence" runat="server" Value="0" />
        <asp:HiddenField ID="lblSumInsured" runat="server" Value="0" />
        <asp:HiddenField ID="txtSumInsured" runat="server" Value="0" />
        <asp:HiddenField ID="lblCarVehicleType" runat="server" Value="0" />
        <asp:HiddenField ID="txtGroupNo" runat="server" Value="-1" />
        <asp:HiddenField ID="ddlVehicleType" runat="server" Value="110" />
    </div>
    <asp:HiddenField runat="server" ID="hdnURLFrom" Value="" />

    <script type="text/javascript">

            $('#CarYear li').click(function(event) {
                event.preventDefault();
                var rel = $(this).attr('rel');
                if (rel != null && rel != "0") {
                    document.getElementById('<%= hdnCarYear.ClientID%>').value = rel;
                    $.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        url: "car-quote.aspx/CarYearClickChanged",
                        data: "{Year:" + rel + "}",
                        dataType: "json",
                        success: function(data) {
                            //alert(data.d);
                            var result = data.d;
                            document.getElementById('ltrCarMake').innerHTML = result;
                            CarMakeClick();
                        },
                        error: function(result) {
                            //alert("Error");
                        }
                    });
                }
                else {
                    document.getElementById('<%= hdnCarYear.ClientID%>').value = "0";
                }
            });

            function my(myvalue) {
                var rel = $(myvalue).attr('rel');
                var makedesc = $(myvalue).text();
                //alert(makedesc);
                if (rel != null && rel != '0' && makedesc != null && makedesc != '0') {
                    document.getElementById('<%= hdnCarMake.ClientID%>').value = rel;
                    document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value = makedesc;
                    //alert(rel);
                    var year = document.getElementById('<%= hdnCarYear.ClientID%>').value;

                    $.ajax({
                        url: "car-quote.aspx/CarMakeClickChanged",
                        type: 'POST',
                        dataType: 'json',
                        contentType: 'application/json',
                        data: JSON.stringify({ CarMake: rel, CarMakeDesc: makedesc, Year: year }),
                        success: function(data) {
                            var result = data.d;
                            document.getElementById('ltrCarModel').innerHTML = result;
                            CarModelClick();
                        },
                        error: function(result) {
                            //alert("Error");
                        }
                    });
                }
                else {
                    document.getElementById('<%= hdnCarMake.ClientID%>').value = "0";
                    document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value = "0";
                }
            }

            $('#ltrCarMake #CarMake').on('click', '.carmake2', function() {
                //$('#CarMake li').click(function (event) {

                //event.stopPropagation();
                //event.preventDefault();
                //alert('hiu');
                var rel = $(this).attr('rel');
                var makedesc = $(this).text();
                if (rel != null && rel != '0' && makedesc != null && makedesc != '0') {
                    document.getElementById('<%= hdnCarMake.ClientID%>').value = rel;
                    document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value = makedesc;
                    var year = document.getElementById('<%= hdnCarYear.ClientID%>').value;
                    //alert(year);
                    //alert(makedesc);
                    $.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        url: "car-quote.aspx/CarMakeClickChanged",
                        data: "{CarMake:" + rel + ",CarMakeDesc:" + makedesc + ",Year:" + year + "}",
                        dataType: "json",

                        success: function(data) {
                            //alert(data);
                            //alert(data.d);
                            var result = data.d;
                            document.getElementById('ltrCarModel').innerHTML = result;
                            CarModelClick();
                        },
                        error: function(result) {
                            //alert("Error");
                        }
                    });
                }
                else {
                    document.getElementById('<%= hdnCarMake.ClientID%>').value = "0";
                    document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value = "0";
                }
            });


            function mo(myvalue) {
                var rel = $(myvalue).attr('rel');
                //var modeldesc = $(myvalue).text();
                var modeldesc = rel;
                if (rel != null && rel != '0' && modeldesc != null && modeldesc != '0') {
                    document.getElementById('<%= hdnCarModel.ClientID%>').value = rel;
                    document.getElementById('<%= hdnCarModelDesc.ClientID%>').value = modeldesc;
                    var year = document.getElementById('<%= hdnCarYear.ClientID%>').value;
                    var make = document.getElementById('<%= hdnCarMake.ClientID%>').value;
                    var makedesc = document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value;
                    var urlfrom = document.getElementById('<%= hdnURLFrom.ClientID%>').value;
                    var islogin = document.getElementById('<%= hdnUserLoginStatus.ClientID%>').value;
                    //alert(year);
                    $.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        //url: "car-quote.aspx/CarModelClickChanged",
                        url: "car-quote.aspx/SaveMobileCarInquiry",
                        data: JSON.stringify({ Year: year, CarMake: make, CarMakeDesc: makedesc, CarModel: rel, CarModelDesc: modeldesc, URLFrom: urlfrom }),
                        dataType: "json",

                        success: function(data) {
                            //alert(data.d);
                            var myString = data.d;
                            var arr = myString.split(':');
                            var domain = window.location.hostname;
                            //alert(domain);
                            if (islogin == "1") {
                                window.location.href = "results.aspx?qid=" + arr[0] + "&cid=" + arr[1] + "&pid=" + arr[2];
                            }
                            else {
                                window.location.href = "your-details.aspx?qid=" + arr[0] + "&cid=" + arr[1] + "&pid=" + arr[2];
                            }
                            //                            document.getElementById('<%= txtSumInsured.ClientID%>').value = arr[0];
                            //                            document.getElementById('<%= lblSumInsured.ClientID%>').value = arr[1];
                            //                            document.getElementById('<%= lblCarVehicleType.ClientID%>').value = arr[2];
                            //                            document.getElementById('<%= txtGroupNo.ClientID%>').value = arr[3];
                            //                            CommenceClick();
                        },
                        error: function(result) {
                            //alert("Error");
                        }
                    });
                }
                else {
                    document.getElementById('<%= hdnCarModel.ClientID%>').value = "0";
                }
            }

            $('#ltrCarModel #CarModel').on('click', '.carmodel2', function() {
                //$('#CarModel li').click(function() {
                var rel = $(this).attr('rel');
                //var modeldesc = $(this).text();
                var modeldesc = rel;
                if (rel != null && rel != '0' && modeldesc != null && modeldesc != '0') {
                    document.getElementById('<%= hdnCarModel.ClientID%>').value = rel
                    document.getElementById('<%= hdnCarModelDesc.ClientID%>').value = modeldesc;
                    var year = document.getElementById('<%= hdnCarYear.ClientID%>').value;
                    var make = document.getElementById('<%= hdnCarMake.ClientID%>').value;
                    var makedesc = document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value;
                    var urlfrom = document.getElementById('<%= hdnURLFrom.ClientID%>').value;
                    var islogin = document.getElementById('<%= hdnUserLoginStatus.ClientID%>').value;
                    //alert(year);
                    $.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        //url: "car-quote.aspx/CarModelClickChanged",
                        url: "car-quote.aspx/SaveMobileCarInquiry",
                        data: "{Year:" + year + ",CarMake:" + make + ",CarMakeDesc:" + makedesc + ",CarModel:" + rel + ",CarModelDesc:" + modeldesc + ",URLFrom:" + urlfrom + "}",
                        dataType: "json",

                        success: function(data) {
                            //alert(data.d);
                            var myString = data.d;
                            var arr = myString.split(':');
                            var domain = window.location.hostname;
                            //alert(domain);
                            if (islogin == "1") {
                                window.location.href = "results.aspx?qid=" + arr[0] + "&cid=" + arr[1] + "&pid=" + arr[2];
                            }
                            else {
                                window.location.href = "your-details.aspx?qid=" + arr[0] + "&cid=" + arr[1] + "&pid=" + arr[2];
                            }
                            //                            document.getElementById('<%= txtSumInsured.ClientID%>').value = arr[0];
                            //                            document.getElementById('<%= lblSumInsured.ClientID%>').value = arr[1];
                            //                            document.getElementById('<%= lblCarVehicleType.ClientID%>').value = arr[2];
                            //                            document.getElementById('<%= txtGroupNo.ClientID%>').value = arr[3];
                            //                            CommenceClick();
                        },
                        error: function(result) {
                        }
                    });
                }
                else {
                    document.getElementById('<%= hdnCarModel.ClientID%>').value = "0";
                }
            });

            //------------------------------------------------//

            function cm(myvalue) {
                var rel = $(myvalue).attr('rel');
                if (rel != null && rel != '0') {
                    document.getElementById('<%= hdnCommence.ClientID%>').value = rel;
                    //alert(rel);
                    var year = document.getElementById('<%= hdnCarYear.ClientID%>').value;
                    var make = document.getElementById('<%= hdnCarMake.ClientID%>').value;
                    var makedesc = document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value;
                    var model = document.getElementById('<%= hdnCarModel.ClientID%>').value;
                    var modeldesc = document.getElementById('<%= hdnCarModelDesc.ClientID%>').value;
                    var suminsured = document.getElementById('<%= txtSumInsured.ClientID%>').value;
                    var carvehicletype = document.getElementById('<%= lblCarVehicleType.ClientID%>').value;
                    var vehicletype = document.getElementById('<%= ddlVehicleType.ClientID%>').value;
                    var groupno = document.getElementById('<%= txtGroupNo.ClientID%>').value;

                    $.ajax({
                        url: "car-quote.aspx/SaveMobileCarInquiry",
                        type: 'POST',
                        dataType: 'json',
                        contentType: 'application/json',
                        data: JSON.stringify({ Year: year, CarMake: make, CarMakeDesc: makedesc, CarModel: model, CarModelDesc: modeldesc, Commencemonth: rel, GroupNo: groupno, CarVehicleType: carvehicletype, VehicleType: vehicletype, SumInsured: suminsured }),
                        success: function(data) {
                        var myString = data.d;
                        //alert(data.d);
                            var arr = myString.split(':');
                            var domain = window.location.hostname;
                            //alert(domain);
                            window.location.href = "results.aspx?qid=" + arr[0] + "&cid=" + arr[1] + "&pid=" + arr[2];
                        },
                        error: function(result) {
                        }
                    });
                }
                else {
                    document.getElementById('<%= hdnCommence.ClientID%>').value = "0";
                }
            }

            $('#ltrCommencement #Commencement').on('click', '.commance2', function() {
                var rel = $(this).attr('rel');
                if (rel != null && rel != '0') {
                    document.getElementById('<%= hdnCommence.ClientID%>').value = rel;
                    var year = document.getElementById('<%= hdnCarYear.ClientID%>').value;
                    var make = document.getElementById('<%= hdnCarMake.ClientID%>').value;
                    var makedesc = document.getElementById('<%= hdnCarMakeDesc.ClientID%>').value;
                    var model = document.getElementById('<%= hdnCarModel.ClientID%>').value;
                    var modeldesc = document.getElementById('<%= hdnCarModelDesc.ClientID%>').value;
                    var suminsured = document.getElementById('<%= txtSumInsured.ClientID%>').value;
                    var carvehicletype = document.getElementById('<%= lblCarVehicleType.ClientID%>').value;
                    var vehicletype = document.getElementById('<%= ddlVehicleType.ClientID%>').value;
                    var groupno = document.getElementById('<%= txtGroupNo.ClientID%>').value;
                    alert(year);
                    $.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        url: "car-quote.aspx/SaveMobileCarInquiry",
                        data: "{Year:" + year + ",CarMake:" + make + ",CarMakeDesc:" + makedesc + ",CarModel:" + model + ",CarModelDesc:" + modeldesc + ",Commencemonth:" + rel + ",GroupNo:" + groupno + ",CarVehicleType:" + carvehicletype + ",VehicleType:" + vehicletype + ",SumInsured:" + suminsured + "}",
                        dataType: "json",

                        success: function(data) {
                            //alert(data.d);
                            var myString = data.d;
                            //alert(data.d);
                            var arr = myString.split(':');
                            var domain = window.location.hostname;
                            //alert(domain);
                            window.location.href = "results.aspx?qid=" + arr[0] + "&cid=" + arr[1] + "&pid=" + arr[2];
                        },
                        error: function(result) {
                        }
                    });
                }
                else {
                    document.getElementById('<%= hdnCommence.ClientID%>').value = "0";
                }
            });


    </script>

    <script type="text/javascript">
            function CarYearClick() {
                document.getElementById('<%= divCarYear.ClientID%>').style.display = '';
                document.getElementById('<%= divCarMake.ClientID%>').style.display = 'none';
                document.getElementById('<%= divCarModel.ClientID%>').style.display = 'none';
                document.getElementById('<%= divCommence.ClientID%>').style.display = 'none';

            }
            function CarMakeClick() {
                document.getElementById('<%= divCarYear.ClientID%>').style.display = 'none';
                document.getElementById('<%= divCarMake.ClientID%>').style.display = '';
                document.getElementById('<%= divCarModel.ClientID%>').style.display = 'none';
                document.getElementById('<%= divCommence.ClientID%>').style.display = 'none';

            }
            function CarModelClick() {
                document.getElementById('<%= divCarYear.ClientID%>').style.display = 'none';
                document.getElementById('<%= divCarMake.ClientID%>').style.display = 'none';
                document.getElementById('<%= divCarModel.ClientID%>').style.display = '';
                document.getElementById('<%= divCommence.ClientID%>').style.display = 'none';
            }
            function CommenceClick() {
                document.getElementById('<%= divCarYear.ClientID%>').style.display = 'none';
                document.getElementById('<%= divCarMake.ClientID%>').style.display = 'none';
                document.getElementById('<%= divCarModel.ClientID%>').style.display = 'none';
                document.getElementById('<%= divCommence.ClientID%>').style.display = '';
            }
            
    </script>

    <%--</div>--%>
</asp:Content>
